package com.ws.array;
/*
数组中常见的异常：
1.数组角标越界的异常：ArrayIndexOutOfBoundsException
2.空指针异常：NullPointerException
 */
public class ArrayException {
    public static void main(String[] args) {

        //1.数组角标越界的异常：ArrayIndexOutOfBoundsException
        int[] arr = new int[]{1,4,2,5};
//        System.out.println(arr[4]);

        //2.空指针异常：NullPointerException
        //情况一：
        int[] arr1 = new int[]{1,2,3};
        arr1 = null;
//        System.out.println(arr1[1]);

        //情况二：
        int[][] arr2 = new int[4][];
//        System.out.println(arr2[0][0]);

        //情况三：
        String[] arr3 = new String[]{"AA", "BB", "CC"};
        arr3[0] = null;
//        System.out.println(arr3[0].toString());

    }
}
